﻿
namespace DingTalk.Common
{
    public static class RedisKeys
    {
        /// <summary>
        /// 系统相关
        /// </summary>
        public static class System
        {
            #region 缓存key
            private static readonly string verifyCodeOfIpCacheKey = "ksax.system.verifycode.ip.{0}";

            private static readonly string wxRequestCodesKey = "ksax.system.wx.requestcodes";

            /// <summary>
            /// 获取验证码IP缓存key
            /// </summary>
            /// <param name="ip"></param>
            /// <returns></returns>
            public static string GetVerifyCodeOfIpCacheKey(string ip)
            {
                return string.Format(verifyCodeOfIpCacheKey, ip);
            }

            /// <summary>
            /// 获取微信请求的code
            /// </summary>
            /// <param name="appId"></param>
            /// <returns></returns>
            public static string GetWXRequestCodesKey()
            {
                return wxRequestCodesKey;
            }

            #endregion

            #region 锁key
            private static readonly string verifyCodeOfMobileLockKey = "ksax.system.verifycode.mobile.{0}";

            /// <summary>
            /// 获取手机号的验证码锁key
            /// </summary>
            /// <param name="mobile"></param>
            /// <returns></returns>
            public static string GetVerifyCodeOfMobileLockKey(string mobile)
            {
                return string.Format(verifyCodeOfMobileLockKey, mobile);
            }
            #endregion
        }

        /// <summary>
        /// 营销相关
        /// </summary>
        public static class Market
        {
            #region 锁key
            private static readonly string drawCouponLockKey = "ksax.market.coupon.draw.{0}";

            /// <summary>
            /// 获取领取优惠券锁key
            /// </summary>
            /// <param name="mobile"></param>
            /// <returns></returns>
            public static string GetDrawCouponLockKey(int couponId)
            {
                return string.Format(drawCouponLockKey, couponId);
            }
            #endregion
        }

        public static class Order
        {
            #region 锁key
            //余额支付锁
            private static readonly string walletPayLockKey = "ksax.order.wallet.pay.{0}";

            /// <summary>
            /// 获取余额支付锁key
            /// </summary>
            /// <param name="userId">用户Id</param>
            /// <returns></returns>
            public static string GetWalletPayLockKey(int userId)
            {
                return string.Format(walletPayLockKey, userId);
            }
            #endregion
        }
    }
}
